package com.cloudbroker.openapi.manage.controller;

import static com.cloudbroker.bcs.platform.dav.common.util.RequestUtil.getSingleParameterMapForBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cloudbroker.bcs.common.entity.HSBCPSBackVO;
import com.cloudbroker.bcs.common.util.VOUtil;
import com.cloudbroker.bcs.platform.dav.bizapi.service.base.vo.PageVO;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.wechat.result.WechatShareDetailResult;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.wechat.vo.WechatShareForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.wechat.vo.WechatShareGetForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.wechat.vo.WechatShareIdForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.business.wechat.vo.WechatShareUpdateForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.export.vo.request.MassMessageForm;
import com.cloudbroker.bcs.platform.dav.bizapi.service.export.vo.response.GetHisMessageBackResult;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.business.WechatShareT2BizService;
import com.cloudbroker.bcs.platform.dav.bizapi.t2service.export.WeixinT2BizService;
import com.cloudbroker.bcs.platform.dav.common.ext.annotation.SaveLog;

/**
 * Created by zhaojp18008 on 2016/5/19.
 */
@Controller
public class WechatShareController {
    @Resource
    private WechatShareT2BizService wechatShareT2;
    
    @Resource
    private WeixinT2BizService weixinT2BizService;

    /**
     * 获取微信分享详情
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_wechat_share_detail_get")
    @SaveLog(remark = "获取微信分享详情")
    public WechatShareDetailResult funcWechatShareDetailGet(HttpServletRequest request, String jsonpcallback) {
        WechatShareGetForm form = getSingleParameterMapForBody(request, WechatShareGetForm.class);
        return VOUtil.setJsonpResult(wechatShareT2.funcWechatShareDetailGet(form), jsonpcallback);
    }
    
    /**
     * 微信分享添加
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_wechat_share_set")
    @SaveLog(remark = "微信分享添加")
    public HSBCPSBackVO funcWechatShareSet(HttpServletRequest request, String jsonpcallback) {
        WechatShareForm form = getSingleParameterMapForBody(request, WechatShareForm.class);
        return VOUtil.setJsonpResult(wechatShareT2.funcWechatShareSet(form), jsonpcallback);
    }
    
    /**
     * 微信分享更新
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_wechat_share_update")
    @SaveLog(remark = "微信分享更新")
    public HSBCPSBackVO funcWechatShareUpdate(HttpServletRequest request, String jsonpcallback) {
        WechatShareUpdateForm form = getSingleParameterMapForBody(request, WechatShareUpdateForm.class);
        return VOUtil.setJsonpResult(wechatShareT2.funcWechatShareUpdate(form), jsonpcallback);
    }
    
    /**
     * 微信分享删除
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_wechat_share_del")
    @SaveLog(remark = "微信分享删除")
    public HSBCPSBackVO funcWechatShareDel(HttpServletRequest request, String jsonpcallback) {
        WechatShareIdForm form = getSingleParameterMapForBody(request, WechatShareIdForm.class);
        return VOUtil.setJsonpResult(wechatShareT2.funcWechatShareDel(form), jsonpcallback);
    }
    
    /**
     * 微信分享次数递增
     * @param request
     * @param jsonpcallback
     * @return
     */
    @ResponseBody
    @RequestMapping("/func_wechat_share_click")
    @SaveLog(remark = "微信分享次数递增")
    public HSBCPSBackVO funcWechatShareClick(HttpServletRequest request, String jsonpcallback) {
        WechatShareIdForm form = getSingleParameterMapForBody(request, WechatShareIdForm.class);
        return VOUtil.setJsonpResult(wechatShareT2.funcWechatShareClick(form), jsonpcallback);
    }
    
    @ResponseBody
    @RequestMapping("/func_mass_message")
    @SaveLog(remark = "微信公众号群发消息")
    public HSBCPSBackVO funcMassMessage(HttpServletRequest request, String jsonpcallback) {
        MassMessageForm form = getSingleParameterMapForBody(request, MassMessageForm.class);
        return VOUtil.setJsonpResult(weixinT2BizService.massMessage(form), jsonpcallback);
    }
    
    @ResponseBody
    @RequestMapping("/func_get_his_message")
    @SaveLog(remark = "获取微信群发历史消息")
    public GetHisMessageBackResult funcGetHisMessage(HttpServletRequest request, String jsonpcallback) {
        PageVO form = getSingleParameterMapForBody(request, PageVO.class);
        return VOUtil.setJsonpResult(weixinT2BizService.funcGetHisMessage(form), jsonpcallback);
    }

}
